﻿using HZU.ZP.Data.Interfaces.Resume;
using HZU.ZP.Data.Models;
using HZU.ZP.Data.Models.Resume;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HZU.ZP.Data.Impl.Resume
{
    public class ProjectExperienceDao:IProjectExperienceDao
    {
        private EFCoreDbContext _context;

        public ProjectExperienceDao(EFCoreDbContext context)
        {
            _context = context;
        }

        public void AddProjectExperience(ProjectExperience projectExperience)
        {
            _context.ProjectExperiences.Add(projectExperience);
            _context.SaveChanges();
        }

        public void DeleteProjectExperience(int id)
        {
            var projectExperience = _context.ProjectExperiences.FirstOrDefault(e => e.Id == id);
            _context.ProjectExperiences.Remove(projectExperience);
            _context.SaveChanges();
        }

        public IList<ProjectExperience> GetProjectExperienceList(int ApplicanId)
        {
            return _context.ProjectExperiences.Where(e => e.ApplicantId == ApplicanId).ToList();
        }

        public void UpdateProjectExperience(ProjectExperience projectExperience)
        {
            _context.ProjectExperiences.Update(projectExperience);
            _context.SaveChanges();
        }
    }
}
